function saveConjugatePrior(filename, conjprior)

fileid = fopen(filename, 'wt');

D = length(conjprior.m0);

if isfield(conjprior, 'a0')
    fprintf(fileid, '%.30g\n', conjprior.a0);
else
    fprintf(fileid, '%.30g\n', 0);
end
fprintf(fileid, ['%d' repmat(' %.30g', 1, D) '\n'], [D conjprior.m0]);
fprintf(fileid, '%.30g\n', conjprior.b0);
fprintf(fileid, '%d %d\n', [D D]);
for i = 1:D
    fprintf(fileid, [repmat('%.30g ', 1, D-1) '%.30g' '\n'], conjprior.W0(i, :));
end
fprintf(fileid, '%d\n', conjprior.v0);

fclose('all');